/**
 * 实现了对于问题命令的解析和求答案
 */
public class AskHandler {
    public void getAnswer(String text){
        ITransform transform = new TransForm();
        //将is后面的放入数组 最后一个是单位
        String[] words = text.replaceAll("[?]","").split("is ")[1].trim().split(" ");
        //得到要转换的罗马数组
        char[] chars =transform.wordsToRoman(words);
        //罗马数组转换为阿拉伯数字
        int sum = transform.toArabic(chars);
        //sum*unit得到总值
        Float unit = RomanNumStatic.unitMap.get(words[words.length-1]);
        if (unit==null){
            System.out.println(text.replaceAll("[?]","").split("is ")[1]+"is "+sum);
        }else {
            System.out.println(text.replaceAll("[?]","").split("is ")[1]+"is "+sum * unit+" Credits");
        }
    }
}
